package com.xiaoxi.observermode.generator;

import java.util.Random;

/**
 * @Author xiaoxi
 * @ProjectName design_mode
 * @PackageName com.xiaoxi.observermode.generator
 * @ClassName RandomNumberGenerator
 * @Description TODO
 * @Date 2023/3/27 15:51
 * @Version 1.0
 */
public class RandomNumberGenerator extends NumberGenerator {

    private Random random = new Random();
    private Integer number;

    @Override
    public Integer getNumber() {
        return number;
    }

    @Override
    public void execute() {
        for (int i = 0; i < 20; i++) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            number = random.nextInt(360);
            notifyObservers();
        }
    }
}
